#include "contiki.h"
#include "shell.h"

#include "collect-common.h"
#include "net/netstack.h"

#include <stdio.h>

#define DEBUG 0
#if DEBUG
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...)
#endif

/*---------------------------------------------------------------------------*/
PROCESS(shell_ipv6_mac_process, "mac ipv6");
SHELL_COMMAND(ipv6_mac_command,
	      "mac",
	      "mac: Turn MAC off(0) / on(1). (0 = keeping radio on)",
	      &shell_ipv6_mac_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_ipv6_mac_process, ev, data)
{

  char *line;

  PROCESS_BEGIN();

  line= data;

  while(*line == ' ') {
    line++;
  }
  PRINTF("Se recibio el caracter %c \n",*line);
  if(*line == '0') {
    NETSTACK_RDC.off(1);
    printf("mac: turned MAC off (keeping radio on): %s\n",
           NETSTACK_RDC.name);
  } else {
    NETSTACK_RDC.on();
    printf("mac: turned MAC on: %s\n", NETSTACK_RDC.name);
  }


  PROCESS_END();
}
/*---------------------------------------------------------------------------*/
void
shell_ipv6_mac_init(void)
{
  shell_register_command(&ipv6_mac_command);
}
/*---------------------------------------------------------------------------*/
